id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Boolean ExpressionsModulo2

prev  |  next  |  chance

%2 is an easy way of testing if a number is odd or even.

public static boolean mod(int num) {
    int result = num % 2;
    return result == 0;
}
Function Call  Return Value
mod(9)        
mod(13)      
mod(10)      
mod(31)      
mod(8)        

Experiment with this code on Gitpod.io

⬅ Back